Skip to content

OCPBUGS-78090: Avoid copy of the oc binary, to support heterogeneous environments#30992

Merged
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
jogeo:OCPBUGS-78090
Apr 10, 2026
Merged

OCPBUGS-78090: Avoid copy of the oc binary, to support heterogeneous environments#30992
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
jogeo:OCPBUGS-78090

Conversation

@jogeo
Copy link
Copy Markdown
Contributor

@jogeo jogeo commented Apr 9, 2026

Copying the oc binary around fails when the environment is a different architecture or has incompatible versions of glibc.
This change instead uses curl to connect the api endpoint, after extracting the sever and cert details from the kubeconfig.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci bot requested review from p0lyn0mial and sjenning April 9, 2026 20:42
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 512e65b9-a996-448f-803f-d22501f02949

📥 Commits

Reviewing files that changed from the base of the PR and between a4a9c33 and a854b14.

📒 Files selected for processing (1)
  • test/extended/apiserver/kubeconfigs.go
✅ Files skipped from review due to trivial changes (1)
  • test/extended/apiserver/kubeconfigs.go

Walkthrough

Replaces copying the host oc binary into the kube-apiserver container and running oc there. Uses oc debug + exec to read the mounted kubeconfig, validate single occurrences of server, client-certificate, client-key, and certificate-authority, extract their values, and call ${server}/api?timeout=32s with curl using the extracted cert/key/CA.

Changes

Cohort / File(s) Summary
Kubeconfig validation and API check
test/extended/apiserver/kubeconfigs.go
Removed steps that copy and execute the host oc binary in the kube-apiserver container. Added oc debug + exec logic to parse the mounted kubeconfig, assert exactly one occurrence of server, client-certificate, client-key, and certificate-authority, extract their values, and perform an HTTPS curl request to the API server using the extracted cert/key/CA.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/extended/apiserver/kubeconfigs.go (1)

121-128: Use POSIX whitespace classes for better portability.

Lines 122 and 125–128 use \s in grep patterns. While this works in the current GNU grep environment, \s is not part of the POSIX standard for BRE/ERE and may not be reliable across different grep implementations or minimal container environments. Replace with [[:space:]] for guaranteed portability:

Proposed fix
-  count=$(grep -Ec "^\s*${k}:\s+" "%[1]s")
+  count=$(grep -Ec "^[[:space:]]*${k}:[[:space:]]+" "%[1]s")
   [ "$count" -eq 1 ] || { echo "expected exactly one ${k} in %[1]s, got $count" >&2; exit 1; }
 done
-server=$(grep '^\s*server:' "%[1]s" | head -1 | awk '{print $2}')
-cert=$(grep '^\s*client-certificate:' "%[1]s" | head -1 | awk '{print $2}')
-key=$(grep '^\s*client-key:' "%[1]s" | head -1 | awk '{print $2}')
-ca=$(grep '^\s*certificate-authority:' "%[1]s" | head -1 | awk '{print $2}')
+server=$(grep -E '^[[:space:]]*server:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
+cert=$(grep -E '^[[:space:]]*client-certificate:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
+key=$(grep -E '^[[:space:]]*client-key:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
+ca=$(grep -E '^[[:space:]]*certificate-authority:[[:space:]]+' "%[1]s" | head -1 | awk '{print $2}')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/apiserver/kubeconfigs.go` around lines 121 - 128, The grep
patterns use the non-POSIX escape `\s` which can break on some grep
implementations; update the patterns in the kubeconfig validation script (the
lines that call grep -Ec "^\s*${k}:\s+" and the subsequent grep calls like grep
'^\s*server:' , grep '^\s*client-certificate:' , grep '^\s*client-key:' and grep
'^\s*certificate-authority:') to use the POSIX whitespace class `[[:space:]]`
(e.g. replace occurrences of `^\s*` and `:\s+` with the equivalent `[[:space:]]`
forms) so the checks are portable across environments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/extended/apiserver/kubeconfigs.go`:
- Line 133: The curl invocation that currently uses the
"${server}/api?timeout=32s" URL (seen in the call that builds the curl command
string in kubeconfigs.go) leaves connection/TLS and network stalls unbounded;
modify the curl command string to add explicit time limits such as
--connect-timeout 10 and --max-time 40 (or similar values) so connection
establishment and the overall request cannot hang indefinitely, ensuring the
constructed command that includes --cert "$cert" --key "$key" --cacert "$ca" and
the "${server}/api?timeout=32s" URL is updated to include these flags.

---

Nitpick comments:
In `@test/extended/apiserver/kubeconfigs.go`:
- Around line 121-128: The grep patterns use the non-POSIX escape `\s` which can
break on some grep implementations; update the patterns in the kubeconfig
validation script (the lines that call grep -Ec "^\s*${k}:\s+" and the
subsequent grep calls like grep '^\s*server:' , grep '^\s*client-certificate:' ,
grep '^\s*client-key:' and grep '^\s*certificate-authority:') to use the POSIX
whitespace class `[[:space:]]` (e.g. replace occurrences of `^\s*` and `:\s+`
with the equivalent `[[:space:]]` forms) so the checks are portable across
environments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f545b9aa-b731-4058-b4c0-3f5eeb7dde97

📥 Commits

Reviewing files that changed from the base of the PR and between 7da3e1c and a4a9c33.

📒 Files selected for processing (1)
  • test/extended/apiserver/kubeconfigs.go

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 9, 2026

/payload-job periodic-ci-openshift-release-main-ci-4.22-e2e-aws-ovn-rhcos10-techpreview

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 9, 2026

@jogeo: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-ci-4.22-e2e-aws-ovn-rhcos10-techpreview

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/be82cf50-345e-11f1-93cb-693c03651f0f-0

@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/retest e2e-aws-ovn-fips

@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/test e2e-aws-ovn-fips

1 similar comment
@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/test e2e-aws-ovn-fips

eval "val=\$$v"
[ -n "$val" ] || { echo "${v} field extraction failed from %[1]s" >&2; exit 1; }
done
curl -Ssf --connect-timeout 10 --max-time 45 --cert "$cert" --key "$key" --cacert "$ca" "${server}/api?timeout=32s"`, kubeconfigPath)).Output()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codrabbitai could this log any sensitive cert details

@dgoodwin
Copy link
Copy Markdown
Contributor

Thanks for picking this up!

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 10, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgoodwin, jogeo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2026
@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

@coderabbitai could this log any sensitive cert details?

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the relevant file to check for logging of sensitive details
fd 'kubeconfigs.go' --exec cat {}

Length of output: 6094


@jogeo Good question — short answer: no sensitive certificate material is logged.

Here's why:

The kubeconfig fields being extracted are client-certificate:, client-key:, and certificate-authority:. These store file paths (e.g., /etc/kubernetes/static-pod-certs/.../tls.key), not the actual cryptographic content. The inline-data variants (client-certificate-data:, client-key-data:, certificate-authority-data:) would contain base64-encoded key/cert bytes, but those fields are never matched or read.

What actually appears in logs:

Source What's logged Sensitive?
framework.Logf("%s", out) JSON response from ${server}/api?timeout=32s (API versions list) No
bash -x trace (stderr) Server URL + file paths like /etc/kubernetes/static-pod-certs/.../tls.key No — paths only, not content
Error messages "expected exactly one ${k} in <kubeconfigPath>, got N" or "${v} field extraction failed" No

The curl invocation passes the file paths as --cert, --key, and --cacert arguments. The actual private key bytes are read by curl internally and never surface in the output or trace.

One minor note: if a kubeconfig happened to use embedded data fields (client-certificate-data:) instead of file paths, the count check would find zero occurrences of client-certificate: and the script would exit with an error before anything is extracted — so there's no accidental leakage path there either.

@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/override e2e-aws-ovn-fips

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

@jogeo: jogeo unauthorized: /override is restricted to Repo administrators, approvers in top level OWNERS file, and the following github teams:openshift: openshift-release-oversight openshift-staff-engineers openshift-sustaining-engineers.

Details

In response to this:

/override e2e-aws-ovn-fips

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/verified by ci

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 10, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@jogeo: This PR has been marked as verified by ci.

Details

In response to this:

/verified by ci

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sosiouxme
Copy link
Copy Markdown
Member

/override ci/prow/e2e-aws-ovn-fips

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

@sosiouxme: Overrode contexts on behalf of sosiouxme: ci/prow/e2e-aws-ovn-fips

Details

In response to this:

/override ci/prow/e2e-aws-ovn-fips

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/retitle OCPBUGS-78090: Avoid copy of the oc binary, to support heterogeneous environments

@openshift-ci openshift-ci bot changed the title Avoid copy of the oc binary, to support heterogeneous environments OCPBUGS-78090: Avoid copy of the oc binary, to support heterogeneous environments Apr 10, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 10, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@jogeo: This pull request references Jira Issue OCPBUGS-78090, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Copying the oc binary around fails when the environment is a different architecture or has incompatible versions of glibc.
This change instead uses curl to connect the api endpoint, after extracting the sever and cert details from the kubeconfig.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Apr 10, 2026
@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Apr 10, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@jogeo: This pull request references Jira Issue OCPBUGS-78090, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @droslean

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from droslean April 10, 2026 20:13
@jogeo
Copy link
Copy Markdown
Contributor Author

jogeo commented Apr 10, 2026

/approved

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 10, 2026

@jogeo: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit ddbb68f into openshift:main Apr 10, 2026
21 checks passed
@openshift-ci-robot
Copy link
Copy Markdown

@jogeo: Jira Issue Verification Checks: Jira Issue OCPBUGS-78090
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-78090 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

Copying the oc binary around fails when the environment is a different architecture or has incompatible versions of glibc.
This change instead uses curl to connect the api endpoint, after extracting the sever and cert details from the kubeconfig.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants